package sg.edu.nus.iss.vmcs.customer;

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import sg.edu.nus.iss.vmcs.util.LabelledDisplay;
import sg.edu.nus.iss.vmcs.util.WarningDisplay;

/**
 * @version 1.1
 * @author Yeo Hee Ling
 */
public class CustomerPanel extends Dialog {

	private static final String TITLE = "Customer Panel";
	private CoinInputBox coinInputBox;	
	private WarningDisplay invalidCoin;
	private LabelledDisplay totalMoney;
	private DrinkSelectionBox drinkSelectionBox;
	private WarningDisplay noChange;
	private Button terminate;
	private LabelledDisplay collectCoin;
	private LabelledDisplay collectCan;
	
	private TransactionController tCtrl;
	
	public CustomerPanel(Frame fr, TransactionController tc) {
		super(fr, TITLE, false);
		tCtrl = tc;
		
		this.setLayout(new BorderLayout());
		pack();
		
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				tCtrl.closeDown();
				dispose();
			}
		});
	}

	public void display() {
		System.out.println("CustomerPanel: before display");
		this.setVisible(true);
		System.out.println("CustomerPanel: after display");
	}

	public void closeDown() {
		dispose();
	}
	
	//to modify
	public void setActive(char component,Boolean st){
		coinInputBox.setActive(st);	
		invalidCoin.setEnabled(st);
		totalMoney.setActive(st);
		drinkSelectionBox.setActive(st);
		noChange.setEnabled(st);
		terminate.setEnabled(st);
		collectCoin.setActive(st);
		collectCan.setActive(st);
	}
	
	//Extra Method
	public DrinkSelectionBox getDrinkSelectionBox(){
		return this.drinkSelectionBox;
	}
	public void setDrinkSelectionBox(DrinkSelectionBox iBox) {
		this.drinkSelectionBox = iBox;
	}
	
	//Extra Method
	public CoinInputBox getCoinInputBox(){
		return this.coinInputBox;
	}
	public void setCoinInputBox(CoinInputBox iBox) {
		this.coinInputBox = iBox;
	}
	
	//Extra Method
	/*
	 * Refund/Change Display
	 */
	public LabelledDisplay getCollectCoinDisplay(){
		return this.collectCoin;
	}
	public void setCollectCoinDisplay(LabelledDisplay iDisplay) {
		this.collectCoin = iDisplay;
	}
	
	//Extra Method
	/*
	 * Can Collection Box Display
	 */
	public LabelledDisplay getCollectCanDisplay(){
		return this.collectCan;
	}
	public void setCollectCanDisplay(LabelledDisplay iDisplay) {
		this.collectCan = iDisplay;
	}
	
	//Extra Method
	/*
	 * TotalMoneyInserted Display
	 */
	public LabelledDisplay getTotalMoneyDisplay(){
		return this.totalMoney;
	}
	public void setTotalMoneyDisplay(LabelledDisplay iDisplay) {
		this.totalMoney = iDisplay;
	}
	
	//Extra Method
	/*
	 * Invalid Coin Display
	 */
	public WarningDisplay getInvalidCoinDisplay(){
		return this.invalidCoin;
	}
	public void setInvalidCoinDisplay(WarningDisplay iDisplay) {
		this.invalidCoin = iDisplay;
	}
	
	//Extra Method
	/*
	 * No Change Available Display
	 */
	public WarningDisplay getNoChangeDisplay(){
		return this.noChange;
	}
	public void setNoChangeDisplay(WarningDisplay iDisplay) {
		this.noChange = iDisplay;
	}
	
	//Extra Method
	/*
	 * Terminate Button
	 */
	public void setTerminateButton(Button iButton) {
		this.terminate = iButton;
	}
}
